using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using HotelManageSystem.Dto;
using HotelManageSystem.Model;
using HotelManageSystem.Service;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;

namespace HotelManageSystem.Controllers {
    [Authorize]
    [ApiController]
    [Route("api/[controller]")]
    public class HotelManage查询Controller : ControllerBase {
        private readonly IHotelManageService _hotelManage;

        public HotelManage查询Controller(IHotelManageService hotelManage) {
            this._hotelManage = hotelManage;
        }
        /// <summary>
        /// 信息总览，
        /// </summary>
        /// <param name="target">
        /// 三种取值，user, worker, room
        /// 指定要查询哪个, Data数据类型随之变化
        /// </param>
        [HttpGet("信息总览查询")]
        public async Task<ActionResult<ServiceResponse<List<object>>>> 信息总览查询(string target) {
            if (target.Equals("user")) {
                return Ok(await _hotelManage.查询所有用户信息());
            }
            else if (target.Equals("worker")) {
                return Ok(await _hotelManage.查询所有员工信息());
            }
            else if (target.Equals("room")) {
                return Ok(await _hotelManage.查询所有房间信息());
            }
            else {
                return BadRequest(new ServiceResponse<string> { Message = "请指定要查询的对象." });
            }        
        }
        /// <summary>
        /// 并不会真的结账，而是返回房间的账单信息等，确认后再调用另一Api"结账"删除入住信息和账单
        /// </summary>
        [HttpGet("按房间Id查询账单信息随后结账")]
        public async Task<ActionResult<ServiceResponse<int>>> 按房间Id查询账单信息随后结账(int roomId) {
            var response = await _hotelManage.按房间Id查询账单信息随后结账(roomId);
            return Ok(response);
        }
        /// <summary>
        /// 按用户Id获取预约信息
        /// </summary>
        [HttpGet("按用户Id查询预定信息")]
        public async Task<ActionResult<ServiceResponse<List<获取预定信息Dto>>>> 按用户Id查询预定信息(string userId) {
            var response = await _hotelManage.按用户Id查询预定信息(userId);
            return Ok(response);
        }
        /// <summary>
        /// 通过ID获取用户信息
        /// </summary>
        [HttpGet("按用户Id查询用户信息")]
        public async Task<ActionResult<ServiceResponse<int>>> 按用户Id查询用户信息(string userId) {
            var response = await _hotelManage.按用户Id查询用户信息(userId);
            return Ok(response);
        }
        /// <summary>
        /// 通过姓名获取用户信息
        /// </summary>
        [HttpGet("按用户名称查询用户信息")]
        public async Task<ActionResult<ServiceResponse<List<GetUserDto>>>> 按用户名称查询用户信息(string userName) {
            var response = await _hotelManage.按用户名称查询用户信息(userName);
            return Ok(response);
        }
        /// <summary>
        /// 
        /// </summary>
        [HttpGet("通过Id查询员工信息")]
        public async Task<ActionResult<ServiceResponse<int>>> 通过Id查询员工信息(int workerId) {
            var response = await _hotelManage.通过Id查询员工信息(workerId);
            return Ok(response);
        }
        /// <summary>
        /// 
        /// </summary>
        [HttpGet("通过名称查询员工信息")]
        public async Task<ActionResult<ServiceResponse<int>>> 通过名称查询员工信息(string workerName) {
            var response = await _hotelManage.通过名称查询员工信息(workerName);
            return Ok(response);
        }
        /// <summary>
        /// 通过ID获取房间信息
        /// </summary>
        [HttpGet("按房间号查询房间信息")]
        public async Task<ActionResult<ServiceResponse<GetRoomDto>>> 按房间号查询房间信息(int roomId) {
            var response = await _hotelManage.按房间号查询房间信息(roomId);
            return Ok(response);
        }
        /// <summary>
        /// 按住户Id搜索入住信息
        /// </summary>
        [HttpGet("按用户Id搜索入住信息")]
        public async Task<ActionResult<ServiceResponse<SearchCheckInInfoDto>>> 按用户Id搜索入住信息(string userId) {
            var response = await _hotelManage.按用户Id搜索入住信息(userId);
            return Ok(response);
        }
        /// <summary>
        /// 
        /// </summary>
        [HttpGet("查看房间账单")]
        public async Task<ActionResult<ServiceResponse<int>>> 查看房间账单(int roomId) {
            var response = await _hotelManage.查询房间账单(roomId);
            return Ok(response);
        }
        /// <summary>
        /// 
        /// </summary>
        [HttpGet("查询预定以及入住时间")]
        public async Task<ActionResult<ServiceResponse<int>>> 查询预定以及入住时间() {
            var response = await _hotelManage.查询预定以及入住时间();
            return Ok(response);
        }
    }
    [Authorize]
    [ApiController]
    [Route("api/[controller]")]
    public class HotelManageController : ControllerBase {
        private readonly IHotelManageService _hotelManage;

        public HotelManageController(IHotelManageService hotelManage) {
            this._hotelManage = hotelManage;
        }
        /// <summary>
        /// 
        /// </summary>
        [HttpPost("登记预定")]
        public async Task<ActionResult<ServiceResponse<int>>> 登记预定(AddPreOrderDto newPreOrder) {
            var response = await _hotelManage.登记预定(newPreOrder);
            return Ok(response);
        }
        /// <summary>
        /// 
        /// </summary>
        [HttpPost("登记用户")]
        public async Task<ActionResult<ServiceResponse<int>>> 登记用户(AddUserDto newUser) {
            var response = await _hotelManage.登记用户(newUser);
            return Ok(response);
        }
        /// <summary>
        /// 
        /// </summary>
        [HttpPost("撤销预定")]
        public async Task<ActionResult<ServiceResponse<int>>> 撤销预定(CancelPreOrderDto canceledPreOrder) {
            var response = await _hotelManage.撤销预定(canceledPreOrder);
            return Ok(response);
        }
        /// <summary>
        /// 
        /// </summary>
        [HttpPost("通过预定入住")]
        public async Task<ActionResult<ServiceResponse<int>>> 通过预定入住(通过预定入住Dto dto) {
            var response = await _hotelManage.通过预定入住(dto.PreOrderId);
            return Ok(response);
        }
        /// <summary>
        /// 
        /// </summary>
        [HttpPost("直接入住")]
        public async Task<ActionResult<ServiceResponse<int>>> 直接入住(入住Dto dto) {
            var response = await _hotelManage.直接入住(dto);
            return Ok(response);
        }
        /// <summary>
        /// 
        /// </summary>
        [HttpPost("添加房间")]
        public async Task<ActionResult<ServiceResponse<int>>> 添加房间(AddRoomDto newRoom) {
            var response = await _hotelManage.添加房间(newRoom);
            return Ok(response);
        }
        /// <summary>
        /// 
        /// </summary>
        [HttpPost("房间变更")]
        public async Task<ActionResult<ServiceResponse<int>>> 房间变更(房间变更Dto dto) {
            var response = await _hotelManage.房间变更(dto);
            return Ok(response);
        }
        /// <summary>
        /// 
        /// </summary>
        [HttpPost("房间状态变更")]
        public async Task<ActionResult<ServiceResponse<int>>> 房间状态变更(房间状态变更Dto dto) {
            var response = await _hotelManage.房间状态变更(dto);
            return Ok(response);
        }
        /// <summary>
        /// 
        /// </summary>
        [HttpPost("房型价格变更")]
        public async Task<ActionResult<ServiceResponse<int>>> 房型价格变更(更改房间价格Dto dto) {
            var response = await _hotelManage.房型价格变更(dto);
            return Ok(response);
        }
        /// <summary>
        /// 
        /// </summary>
        [HttpPost("添加账单")]
        public async Task<ActionResult<ServiceResponse<int>>> 添加账单(添加账单Dto dto) {
            var response = await _hotelManage.添加账单(dto);
            return Ok(response);
        }
        /// <summary>
        /// 
        /// </summary>
        [HttpPost("结账")]
        public async Task<ActionResult<ServiceResponse<int>>> 结账(结账Dto dto) {
            var response = await _hotelManage.结账(dto.RoomId);
            return Ok(response);
        }

    }

}